package com.naizhuai.util;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.widget.Toast;

import com.naizhuai.R;

/**
 * Created by code_han on 2018/3/1.
 */

public class PhoneUtils {

    /**
     * 直接拨打电话
     * @param phoneNum 电话号码
     */
    public static void CallPhone(String phoneNum, Context mContext) {
        Intent intent = new Intent(Intent.ACTION_CALL);
        Uri data = Uri.parse("tel:" + phoneNum);
        intent.setData(data);
        if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
            mContext.startActivity(intent);
        }else{
            ToastCompat.showToast(mContext,mContext.getText(R.string.request_permission_fail),Toast.LENGTH_SHORT);
        }
    }
}
